package com.spark.localvector

import org.apache.spark.mllib.linalg.Vectors

/**
  * Created by Administrator on 2017/8/21.
  */
object localVector {

  def main(args: Array[String]): Unit = {

    val v1 = Vectors.dense(4, 0.0, 3.0)
    val v2 = Vectors.sparse(3, Array(0, 2), Array(1.0, 3.0))
    val v3 = Vectors.sparse(3, Seq((0, 1.0), (2, 3.0)))


    sparse(3, Seq((0, 1.0), (2, 3.0)))

  }

  def sparse(size: Int, seq: Seq[(Int, Double)]): Unit = {

    println(size)
    println(seq.sortBy(_._1))
    println(seq.sortBy(_._1).unzip)
    val (index, data) = seq.sortBy(_._1).unzip

    println(index)
    println(data)


  }

  def sum(other: Int*) = {
    other.sum
  }

}
